<?php
namespace Admin\Controller;

class AuthManagerController extends AdminController{
    
    /**
     * 权限管理首页
     * 
     * 在用户类别的用户管理子类别下
     */
    public function index(){
        //显示所有组
        $auth_group = M("AuthGroup");
        $groups = $auth_group->where(array("status" => 1))->select();
        $this->assign("groups",  $groups);
        $this->display('form');
        
    }
    
    /**
     * 访问授权
     * 
     * 显示编辑用户访问权限编辑页
     */
    public function access($groupid="", $groupname=""){
        $tree = $this->returnNodes();
        $group = array(
            "groupid"   => $groupid,
            "groupname" => $groupname
                );
        
//        foreach($tree as $key => $value){
//            echo "<h1>" .$value['title']. "</h1>";
//            
//            if(isset($value['child'])){                
//                foreach ($value['child'] as $ckey => $cvalue){
//                    echo "<h3>" .$cvalue['title']. "</h3>";
//                    
//                    if(isset($cvalue['operator'])){                        
//                        foreach ($cvalue['operator'] as $okey => $ovalue){
//                            echo $ovalue['title']. "&nbsp&nbsp";
//                        }
//                    }
//                    echo '<br>';
//                }
//            }
//            echo "<hr>";
//        }

        $this->assign(array("tree" => $tree, "group" => $group));
        $this->display("edit_access");
    }
    
    /**
     * 更新组权限
     * 
     * 通过更改组的权限，从而改变普通管理用户的管理权限
     */
    public function updateGroup(){
        
    }
}